package On_class.L0408;

import java.io.*;
import java.rmi.server.ExportException;

public class BufferedInputStreamCopy {
    public static void main(String[] args) throws IOException {
        InputStream in=null;
        long start=System.currentTimeMillis();
        try{
            in=new FileInputStream("D://copy1.rar");

        }catch (FileNotFoundException e){
            e.printStackTrace();
        }
        BufferedInputStream bis=null;
        BufferedOutputStream bos=null;
        try {
            bis=new BufferedInputStream(in);
            bos=new BufferedOutputStream(new FileOutputStream("copy.rar"));
            byte[] by=new byte[1024];
            int len=0;
            while((len=bis.read(by))!=-1){
                bos.write(by,0,len);

            }
        }catch (Exception e){
            e.printStackTrace();
        }
        finally {
            if(bos!=null){
                bos.close();
            }
            if(bis!=null){
                bis.close();
            }
        }
        long end=System.currentTimeMillis();
        System.out.println(end-start);
    }
}
